// pages/video/video.js
import { getDataForIndex } from '../../service/index.js';
const app = getApp()

Page({
  data: {
    vedios: [],
    top:''
  },
  onLoad(options) {
    console.log(options)
    this._getDataForIndex()
  },
  videoEndFun() {
    wx.switchTab({url: '/pages/appointment/appointment'})
    console.log('视频播放结束')
  },
  _getDataForIndex() {
    getDataForIndex(1, 999).then(res => {
      if (res.code == 200) {
        this.setData({ vedios: res.data.vedios })
        var query = wx.createSelectorQuery();	// 创建节点查询器 query
        //选择id
        let that = this; // 获取this
        // 这段代码的意思是选择class=every的节点，获取节点位置信息的查询请求
        query.select('#myvideo').boundingClientRect(function (rect) {
          console.log(rect)
          wx.getSystemInfo({
            success: function (res) {
              let clientHeight = res.windowHeight;
              let clientWidth = res.windowWidth;
              let ratio = 750 / clientWidth;
              let height1 = clientHeight * ratio;
              that.setData({
                top: height1 - (height1 - rect.height)/2
              });
            }
          });
        }).exec();
        query.selectViewport().scrollOffset().exec()//这段代码的意思是获取页面滑动位置的查询请求
      }
    })
  }
})